package com.example.jk.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.jk.entity.JBody;
import com.example.jk.service.JBodyService;
import com.example.jk.mapper.JBodyMapper;
import com.example.jk.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
* @author 谭博宇
* @description 针对表【j_body】的数据库操作Service实现
* @createDate 2025-06-30 15:45:12
*/
@Service
public class JBodyServiceImpl extends ServiceImpl<JBodyMapper, JBody>
    implements JBodyService{
    @Autowired
    JBodyMapper jBodyMapper;

    @Override
    public Result selectpage(JBody jBody) {
        Page<JBody> page =new Page<JBody>(jBody.getPage(),jBody.getSize());
        //条件查询
        QueryWrapper<JBody> queryWrapper = new QueryWrapper<JBody>();
        if(jBody.getName()!=null&&!"".equals(jBody.getName())) {
            queryWrapper.like("name", jBody.getName());
        }
        jBodyMapper.selectPage(page,queryWrapper);
        List<JBody> list = page.getRecords();
        long total =page.getTotal();
        HashMap<String,Object> hashMap = new HashMap<String, Object>();
        hashMap.put("list",list);
        hashMap.put("total",total);
        return new Result(200,"查询成功",hashMap);
    }
}




